<template>
	<view>
		<view @click="tosortinfo(sortlist[0].id)" class="sort-one">
			<text>{{sortlist[0].name}}</text>
			<image :src="sortlist[0].icon" mode=""></image>
		</view>
		<view @click="tosortinfo(sortlist[1].id)" class="sort-one sort-two">
			<text>{{sortlist[1].name}}</text>
			<image :src="sortlist[1].icon" mode=""></image>
		</view>
		<view class="sort-three">
			<view @click="tosortinfo(sortlist[2].id)" class="item">
				<text>{{sortlist[2].name}}</text>
				<image :src="sortlist[2].icon" mode=""></image>
			</view>
			<view @click="tosortinfo(sortlist[3].id)" class="item">
				<text>{{sortlist[3].name}}</text>
				<image :src="sortlist[3].icon" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		findCategory,
		findAllCategory
	} from '../../api/sort/sort.js'
	export default {
		data() {
			return {
				sortlist: ''
			}
		},
		methods: {
			init() {
				// 获取分类列表
				findCategory('1308336521604599809').then(res => {
					this.sortlist = res.data.category.children
				})
			},
			// 到分类详细页面
			tosortinfo(ids) {
				console.log(ids);
				uni.navigateTo({
					url: `./sortinfo/sortinfo?id=${ids}`
				})
			}
		},
		onLoad() {
			this.init()
		}

	}
</script>

<style lang="scss" scoped>
	.sort-one {
		height: 300rpx;
		width: 670rpx;
		background-color: #D5D5D5;
		display: flex;
		justify-content: space-between;
		border-radius: 20rpx;
		box-sizing: border-box;
		overflow: hidden;
		margin: 40rpx auto;
		box-shadow: 0 16rpx 48rpx 0 rgba(122, 98, 75, 0.12);

		text {
			font-size: 48rpx;
			line-height: 300rpx;
			margin-left: 40rpx;
			box-sizing: border-box;
		}

		image {
			width: 400rpx;
			box-sizing: border-box;
			height: 300rpx;
		}
	}

	.sort-two {
		background-color: #FAFAFA;
		margin-top: 40rpx;
		box-sizing: border-box;
	}

	.sort-three {
		height: 400rpx;
		width: 670rpx;
		display: flex;
		justify-content: space-between;
		overflow: hidden;
		margin: 40rpx auto;
		box-sizing: border-box;

		.item {
			width: 310rpx;
			height: 400rpx;
			border-radius: 20rpx;
			overflow: hidden;
			box-sizing: border-box;
			position: relative;
			display: flex;
			box-shadow: 0 8px 24px 0 rgba(122, 98, 75, 0.12);

			image {
				width: 310rpx;
				height: 400rpx;
				position: absolute;
				left: 0;
				top: 0;
				box-sizing: border-box;
				z-index: 0;
			}

			text {
				position: relative;
				z-index: 11;
				margin: auto;
				margin-left: 20rpx;
				box-sizing: border-box;
				margin-top: 80rpx;
				font-size: 48rpx;
			}
		}
	}
</style>
